package com.nageoffer.jobtrain.projects.common.config;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 阿里云短信验证码配置类
 * author：唐晨
 */
@Configuration
public class AliYunSmsConfiguration {
    /**
     * 访问id
     */
    @Value("${sms.aliyun.accessKeyId}")
    private String accessKeyId;

    /**
     * 访问密钥
     */
    @Value("${sms.aliyun.accessKeySecret}")
    private String accessKeySecret;

    /**
     * 访问地址
     */
    @Value("${sms.aliyun.endpoint}")
    private String endpoint;

    @Bean(name = "aliyunSmsClient")
    public Client createClient() throws Exception {
        Config config = new Config()
                .setAccessKeyId(accessKeyId)
                .setAccessKeySecret(accessKeySecret)
                .setEndpoint(endpoint);
        return new Client(config);
    }
}
